<template>
  <div class="body">
    <header
      class="every_header"
      style="
        background: url('https://img.alicdn.com/imgextra/i4/2053469401/O1CN011TM4Zn2JJi1K2DdqC_!!2053469401.png')
          0% 0% / 100% no-repeat;
      "
    >
      <div class="title">
        <van-icon name="arrow-left" class="icon" @click="re" />

        <span>5.5吾折天</span>
      </div>
    </header>
    <div class="layout">
      <div class="banner">
        <img
          src="https://img.alicdn.com/imgextra/i2/2053469401/O1CN01wU8kUJ2JJi1HrBIIF_!!2053469401.png"
        />
      </div>

      <van-tabs
        v-model:active="active"
        scrollspy
        sticky
        offset-top=".45rem"
        background="rgb(237,8,115)"
        line-width=".4rem"
        title-active-color="#9812A4"
        title-inactive-color="#FFFFFFA6"
        @click="dj"
      >
        <van-tab :title="item.title" v-for="(item, i) in star1" :key="item.id">
          <div class="floor floor_1" id="floor_1" isload="true" v-if="star2">
            <div>
              <h4 class="floor_title text-center">{{ item.title }}</h4>
            </div>
            <div class="subhead text-center">{{ item.title_two }}</div>
            <div
              class="
                sw_product_lists
                swiper-container
                swiper-container-horizontal
                swiper-container-free-mode
              "
            >
              <div
                class="swiper-wrapper"
                style="
                  transform: translate3d(0px, 0px, 0px);
                  transition-duration: 300ms;
                "
                v-if="star2.stars[i]?.data.vertical"
              >
                <div
                  class="swiper-slide sw_product_list swiper-slide-active"
                  v-for="j in star2.stars[i]?.data?.vertical"
                  :key="j.id"
                >
                  <div class="img_group">
                    <img :src="j.pic_url" alt="" /><span class="self_label"
                      >{{ j.self_selling_point }}
                    </span>
                  </div>
                  <div class="title text-ellipsis">{{ j.name }}</div>
                  <div class="price yure">
                    ¥<span class="juan_jia yure"> {{ j.sale_price }} </span>
                    <span class="yuan_jia">¥{{ j.price }}</span>
                  </div>
                  <div class="label">
                    <span class="sales_msg">爆卖</span>
                    <span class="sales"> {{ j.month_sale_num }}</span>
                    <span>件</span>
                  </div>
                  <div class="peo_num">
                    <span>{{ j.want_to_buy_num }} </span>人想买
                  </div>
                </div>

                <!-- </div>
                </div> -->
              </div>
              <div
                class="swiper-wrapper"
                style="
                  transform: translate3d(0px, 0px, 0px);
                  transition-duration: 300ms;
                "
                v-else
              >
                <div
                  class="swiper-slide sw_product_list swiper-slide-active"
                  v-for="j in star2.stars[i]?.data"
                  :key="j.id"
                >
                  <div class="img_group">
                    <img :src="j.pic_url" alt="" /><span class="self_label"
                      >{{ j.self_selling_point }}
                    </span>
                  </div>
                  <div class="title text-ellipsis">{{ j.name }}</div>
                  <div class="price yure">
                    ¥<span class="juan_jia yure"> {{ j.sale_price }} </span>
                    <span class="yuan_jia">¥{{ j.price }}</span>
                  </div>
                  <div class="label">
                    <span class="sales_msg">爆卖</span>
                    <span class="sales"> {{ j.month_sale_num }}</span>
                    <span>件</span>
                  </div>
                  <div class="peo_num">
                    <span>{{ j.want_to_buy_num }} </span>人想买
                  </div>
                </div>
              </div>
            </div>
            <div v-if="star2.stars[i]?.data.horizontal"></div>
            <div
              class="product_lists"
              v-for="index in star2.stars[i]?.data.horizontal"
              :key="index.id"
            >
              <img
                ui-lazyload=""
                :src="index.pic_url"
                data-original="//gju3.alicdn.com/tps/i3/O1CN01PUwRyO1DJoIsNBLSS_!!0-juitemmedia.jpg_310x310.jpg_.webp"
                alt=""
                isload="true"
                style="background: rgb(245, 245, 245); display: block"
              />
              <div class="title text-ellipsis">
                {{ index.name }}
              </div>
              <div class="price">
                <span class="price_label text-center yure ju"></span>
                <span class="yure">¥</span
                ><span class="juan_jia yure"> {{ index.sale_price }} </span>
                <span class="yuan_jia">¥{{ index.price }} </span>
                <span class="red_bubble"
                  >限时价<span class="triangle"></span
                ></span>
              </div>
              <div class="msg"><span>爆款直降</span></div>
              <div class="peo_num">
                <span> {{ index.want_to_buy_num }} </span>人想买
              </div>
              <div class="action_btn yure">加入购物车</div>
            </div>
          </div>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script lang="ts">
import router from "@/router";
import { computed, defineComponent, onMounted } from "vue";
import { useStore } from "vuex";
export default defineComponent({
  setup() {
    const store = useStore();
    const re = () => {
      router.go(-1);
    };
    onMounted(() => {
      store.dispatch({
        type: "star1/getstar",
        r: "half/getfloor",
        token: "false",
        terminal: "wap",
      });
      store.dispatch({
        type: "star2/getstar",
        floor_id: "1",
        token: "false",
        terminal: "wap",
      });
      store.dispatch({
        type: "star2/getstar",
        floor_id: "25",
        token: "false",
        terminal: "wap",
      });
      store.dispatch({
        type: "star2/getstar",
        floor_id: "27",
        token: "false",
        terminal: "wap",
      });
      store.dispatch({
        type: "star2/getstar",
        floor_id: "29",
        token: "false",
        terminal: "wap",
      });
      store.dispatch({
        type: "star2/getstar",
        floor_id: "30",
        token: "false",
        terminal: "wap",
      });
      store.dispatch({
        type: "star2/getstar",
        floor_id: "33",
        token: "false",
        terminal: "wap",
      });
    });
    const star1 = computed(() => store.state.star1.stars.data);
    const star2 = computed(() => store.state.star2);
    console.log(star2);

    return { star1, star2, re };
  },
});
</script>

<style lang="stylus" scoped>
.body {
  background: #F6F6F6;
}

body, button, dd, dl, dt, h1, h2, h3, h4, h5, h6, html, input, li, ol, p, select, textarea, ul {
  word-wrap: break-word;
  white-space: normal;
  word-break: break-all;
}

body, html {
  font-size: 14px;
  font-family: Arial, Helvetica, sans-serif, 'Microsoft YaHei';
  padding: 0;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}

.sw_product_lists {
  overflow: auto;
}

/deep/.van-tabs__line {
  background: #9812a4;
}

.every_header {
  width: 100%;
  position: fixed;
  z-index: 99;

  .title {
    line-height: 35px;
    color: #fff;
    font-weight: 400;
    overflow: hidden;
    font-size: 18px;
    text-align: center;
    padding: 5px 10px;
  }

  .icon {
    position: absolute;
    zoom: 1;
    left: 10px;
    font-size: 18px;
    z-index: 99;
    font-weight: 500;
    line-height: 0.35rem;
  }
}

.layout {
  background: url('https://img.alicdn.com/imgextra/i4/2053469401/O1CN011TM4Zn2JJi1K2DdqC_!!2053469401.png') 0% 0% / 100% no-repeat;
  max-width: 750px;
  text-align: left;
  margin: auto;
  overflow: auto;
  padding-top: 0.45rem;

  .banner {
    display: block;
    overflow: hidden;
    max-width: 750px;
    height: 168px;

    img {
      width: 100%;
      height: 100%;
    }
  }
}

.floor {
  background: none;
  margin-bottom: 20px;
  padding-top: 96px;
  margin-top: -96px;

  .floor_title {
    margin: 0 auto;
    font-size: 15px;
    font-weight: 500;
    color: #3a3836;
    line-height: 21px;
    position: relative;
    z-index: 1;
    zoom: 1;
    text-align: center;

    &:after {
      background: url('https://img.alicdn.com/imgextra/i1/2053469401/O1CN01ufITU62JJhzOiaSZA_!!2053469401.png') no-repeat center;
      content: '';
      width: auto;
      height: 32px;
      left: 0;
      right: 0;
      margin: auto;
      display: inline-block;
      position: absolute;
      z-index: 1;
      zoom: 1;
      top: -2px;
      background-size: auto 32px;
    }
  }

  .subhead {
    font-size: 10px;
    font-weight: 400;
    color: #3a3836;
    line-height: 14px;
    text-align: center;
  }
}

.sw_product_lists {
  margin: 11px 10px 10px;
  padding: 0 10px;

  .swiper-wrapper {
    display: flex;
  }

  .sw_product_list {
    width: 110px;
    background: #fff;
    border-radius: 8px;
    margin-right: 5px;
    padding: 0 5px 5px;
    box-sizing: border-box;

    img {
      width: 100px;
      height: 100px;
      background: pink;
      border-radius: 5px;
      margin: 5px 0 6px;
      display: block;
    }

    .title {
      height: 14px;
      font-size: 10px;
      font-weight: 400;
      color: #333;
      line-height: 14px;
    }

    .price {
      font-size: 11px;
      font-weight: 400;
      color: #FF0637;
      line-height: 17px;
      margin: 3px 0;

      .juan_jia {
        font-size: 16px;
        font-weight: 500;
        margin: 0 1px;
      }

      .yuan_jia {
        font-size: 10px;
        color: #A7A7A7;
        text-decoration: line-through;
      }
    }

    .label {
      background-size: 90px 25px;
      width: 90px;
      height: 25px;
      transform: translateX(-5px);
      padding-left: 5px;
      font-size: 10px;
      font-weight: 400;
      line-height: 18px;
      color: #fff;
      box-sizing: border-box;

      .sales_msg {
        color: #CE4F08;
        margin-right: 13px;
      }

      span {
        height: 25px;
        display: inline-block;
      }

      .sales {
        font-size: 11px;
      }
    }

    .peo_num {
      font-size: 10px;
      font-weight: 400;
      color: #666;

      span {
        font-size: 12px;
        color: #FF0637;
        margin-right: 2px;
      }
    }
  }
}

.text-ellipsis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.yure {
  color: #2AA451 !important;
}

.img_group {
  position: relative;
  z-index: 1;
  zoom: 1;

  .self_label {
    position: absolute;
    z-index: 1;
    zoom: 1;
    left: 0;
    bottom: 0;
    height: 14px;
    background: linear-gradient(270deg, #ffb400 0, #ff851c 100%);
    padding: 0 8px;
    font-size: 10px;
    font-weight: 400;
    color: #fff;
    text-overflow: ellipsis;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 0 6px 0 0;
  }
}

.product_lists {
  margin: 10px 10px 0;
  padding: 7px;
  height: 124px;
  background: #fff;
  box-sizing: border-box;
  border-radius: 8px;
  position: relative;
  z-index: 1;
  zoom: 1;

  .action_btn {
    width: 70px;
    height: 38px;
    border-radius: 5px;
    box-shadow: 0 1px 2px #ff3860;
    background: linear-gradient(270deg, #fe6503 0, #ff3860 100%);
    position: absolute;
    z-index: 1;
    zoom: 1;
    bottom: 7px;
    right: 7px;
    color: #fff;
    padding: 4px;
    box-sizing: border-box;
  }

  img {
    width: 110px;
    height: 110px;
    background: pink;
    display: block;
    float: left;
    margin-right: 12px;
    border-radius: 5px;
  }

  .title {
    height: 18px;
    font-size: 13px;
    font-weight: 400;
    color: #333;
    line-height: 18px;
  }

  .price {
    font-size: 12px;
    font-weight: 400;
    color: #FF0637;
    line-height: 17px;
    margin: 5px 0;

    .price_lable {
      width: 14px;
      height: 14px;
      background: #ed080a;
      border-radius: 3px;
      line-height: 14px;
      color: #fff !important;
      font-size: 10px;
      font-weight: 500;
      display: inline-block;
      float: left;
      margin-top: 2px;
      margin-right: 5px;
    }

    .juan_jia {
      font-size: 18px;
      font-weight: 500;
      margin: 0 2px;
    }

    .yuan_jia {
      font-size: 10px;
      color: #A7A7A7;
      text-decoration: line-through;
    }
  }

  .msg {
    margin-bottom: 0.07px;
    display: flex;

    span {
      height: 15px;
      background: #ffeecd;
      border-radius: 2px;
      font-size: 10px;
      font-weight: 400;
      color: #E2631C;
      line-height: 15px;
      display: inline-block;
      padding: 0 4px;
    }
  }

  .labels {
    display: inline-block;
    transform: translateY(-2px);
  }

  .peo_num {
    font-size: 10px;
    font-weight: 400;
    color: #666;
    margin-top: 30px;

    span {
      font-size: 12px;
      color: #FF0637;
      margin-right: 2px;
    }
  }
}

.action_btn.yure {
  width: 83px;
  height: 26px;
  font-size: 12px;
  color: #fff !important;
  line-height: 26px;
  box-shadow: none;
  text-align: center;
  background-size: 83px 34px;
  padding: 0;
  border-radius: 0;
  bottom: 10;
  background: rgb(52, 184, 96);
  border-radius: 4px;
}

.red_bubble {
  position: relative;
  z-index: 1;
  zoom: 1;
  font-size: 9px;
  font-weight: 400;
  color: #fff;
  background: linear-gradient(150deg, #fe3a33 0, #fb8d2c 100%);
  padding: 0 3px;
  margin-left: 5px;
  top: -2px;
  height: 12px;

  .triangle {
    position: absolute;
    zoom: 1;
    left: -4px;
    top: 0;
    width: 0;
    height: 0;
    z-index: -1;
    border-color: #f8403a transparent transparent;
    border-width: 6px 8px;
    border-style: solid;
    transform: rotate(-1deg);
  }
}
</style>
